/**
 * Author:beyondboy
 * Gmail:xuguoli.scau@gmail.com
 * Date: 2015-04-13
 * Time: 13:00
 */
package com.scau.beyondboy.geoquiz;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.scau.beyondboy.model.TrueFalse;


public class CheatActivity extends Activity
{
    public static final String EXTRA_ANSWER_SHOWN="";
    public static final String EXTRA_ANSWER_IS_TRUE="com.bignerdranch.android.geoquiz.answer_shown";
    private static final String TAG = "CheatActivity";
    private Button mShowAnswerButton;
    private TextView mAnswerTextView;
    private boolean mAnswerIsTrue;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cheat);
        mAnswerIsTrue=getIntent().getBooleanExtra(CheatActivity.EXTRA_ANSWER_IS_TRUE,false);
        setAnswerShownResult(false);
        mShowAnswerButton=(Button)findViewById(R.id.showAnswer_button);
        mAnswerTextView=(TextView)findViewById(R.id.answerTextView);
        mShowAnswerButton.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                Log.i(TAG,"查看答案" );
                if(mAnswerIsTrue)
                {
                    mAnswerTextView.setText(R.string.true_button);
                }
                else
                {
                    mAnswerTextView.setText(R.string.false_button);
                }
                setAnswerShownResult(true);
            }
        });
    }
    //返回结果到MainActivity
    private void setAnswerShownResult(boolean isAnswerShown)
    {
        Log.i(TAG,"返回结果到MainActivity");
        Intent data=new Intent();
        data.putExtra(CheatActivity.EXTRA_ANSWER_SHOWN,isAnswerShown);
        setResult(RESULT_OK,data);
    }
}
